<?php


class Blackbird_Model_Banners extends Zend_Db_Table
{
	function fetchBannerRedirectionBySlug($slug)
	{
		$db = $this->getAdapter();
		$sql = 'select bannerId, url'
			. "\n	from bb_banner"
			. "\n	where slug = " . $db->quote($slug);
			;
		$banner = $db->fetchRow($sql);
		$sql = 'update bb_banner set clicks = clicks + 1'
			. "\n	where bannerId = " . $banner->bannerId
			;
		$db->query($sql);
		return $banner->url;
	}
}

